﻿using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
using System;
using System.Collections.Generic;

namespace Sustainalytics.Entities.RiskRatings
{
    public class RiskRatingResearchProfileBase : IEntity
    {
        #region Shared Entities fields

        public Guid Id { get; set; }
        public string CompanyName { get; set; }
        public int CompanyId { get; set; }
        public int CompanyProfileVersion { get; set; }
        public ManagementRisk ManagementRisk { get; set; }
        public DateTime LastUpdate { get; set; }

        public RiskRatingCluster Cluster { get; set; }
        public Timestamped<RiskRatingClusterAssessment> Assessment { get; set; }
        public Timestamped<ExposureClusterAssessment> ExposureCluster { get; set; }
        public Timestamped<ManagementClusterAssessment> ManagementCluster { get; set; }
        public Timestamped<ManageableClusterAssessment> ManageableCluster { get; set; }

        public string PublishProcessInfo { get; set; }

        public Timestamped<string> BusinessModelComment { get; set; }
        public Timestamped<string> ExposureComment { get; set; }
        public Timestamped<string> EsgRiskManagementComment { get; set; }
        public Timestamped<string> AnalystViewOverallAssessment { get; set; }
        public Timestamped<string> OverallExposureAssessment { get; set; }
        public Timestamped<string> OverallManagementAssessment { get; set; }
        public Timestamped<string> AnalystViewOverallConsolidated { get; set; }
        public Timestamped<double> SubIndustryExposureScore { get; set; }

        #endregion

        #region GA Specific fields

        public string PeerGroup { get; set; }
        public string SubPeerGroup { get; set; }
        public int SubPeerGroupId { get; set; }
        public string Country { get; set; }
        public string Exchange { get; set; }
        public string Ticker { get; set; }
        public string ExchangeTicker { get; set; }
        public double? MarketCapitalization { get; set; }

        #endregion

        public Timestamped<double> OverallExcessExposure { get; set; }
    }

    [BsonIgnoreExtraElements]
    public class RiskRatingResearchProfile : RiskRatingResearchProfileBase
    {
        public IEnumerable<ThemeScore> ThemeScores { get; set; }
        public IEnumerable<RiskRatingMaterialEsgIssueBase> MaterialEsgIssues { get; set; }

        public Timestamped<double> OverallBetaFactor { get; set; }
    }

    [BsonIgnoreExtraElements]
    public class CoreRiskRatingResearchProfile : RiskRatingResearchProfileBase
    {
        public Timestamped<double> ManageableRiskFactorPercentile { get; set; }
        public Timestamped<double> BetaFactor { get; set; }
        public Timestamped<double> FinalBetaFactor { get; set; }
        public Timestamped<double> IndentPercentile { get; set; }

        public IEnumerable<CoreRiskRatingIndicator> Indicators { get; set; }

        #region To delete after Risk Rating market launch

        public Timestamped<string> AnalystView { get; set; }

        [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
        public IDictionary<int, Timestamped<string>> Sentences { get; set; }

        #endregion
    }
}
